<?php

	$request = $controller->getRequest();
	$user = $controller->getCurrentUser();
	
	if ($request->getMethod() == 'POST')
	{
		try 
		{
			$lastname = $request->getParam('lastname');
			$firstname = $request->getParam('firstname');
			$email = $request->getParam('email');
			//$badge = intval($request->getParam('badge'));
			$grade = intval($request->getParam('grade'));
			$semester = intval($request->getParam('semester'));
			$comment = $request->getParam('comment');
			$saverecords = $request->getParam('saverecords') ? true : false;
			$paid = $request->getParam('paid') ? true : false;
			$deposit = $request->getParam('deposit') ? true : false;
			$newuser = user::newUser($lastname, $firstname, $email, 1, $grade, $semester, $saverecords, $paid, $deposit, $comment);
			
			logPermactions($user->getId(),'Nouvel utilisateur : '.$newuser->getCompleteName());		
						
			if (is_null($newuser))
				$controller->addError('E-mail d&eacute;j&agrave; saisi ! Si l\'utilisateur est d&eacute;j&agrave; inscrit, vous pouvez &eacute;diter son profil sur la page "Modifier d\'un utilisateur"');		
			else
				$controller->addInformation('Ajout effectu&eacute;');
		}
		catch (Exception $e)
		{
			$e->_log();
			$controller->addError('L\'ajout n\'a pas pu &ecirc;tre effectu&eacute;.');
		}
	}
	
	$controller->setVar('user', $user);
	$controller->render("addUser");
	
?>